/**
 * @author harae Feng 
 * @date 2019-09-17 16:11:07 
 * @Last Modified by: harae Feng
 * @Last Modified time: 2019-09-17 16:39:40
 * @Describe 测试node-fetch的使用情况
 */

 const fetch = require('node-fetch')

 const Bluebired = require('bluebird')

 testResJSON()
 async function testResJSON(){
    try {
        let url = `https://www.iesdouyin.com/web/api/v2/hotsearch/billboard/star/`
        let res = await fetch(url)
        let headersMap = res.headers // map类型
        let cookie = res.headers.get('cookie')
        let contentType = res.headers.get('content-type')
        let headersRaw = res.headers.raw()
        let result = await res.json()
        console.log(`--[log]-[FUNCTION]testResJSON, request:${url} , res: ${Object.prototype.toString.call(result)}`)
    } catch (error) {
        console.warn(error)
    }
}

// testResText()
async function testResText(){
    try {
        let url = `https://github.com/`
        let result = await fetch(url)
        let res = await result.text()
        console.log(`--[log]-[FUNCTION]testResText, request:${url} , res: ${Object.prototype.toString.call(res)}`)
    } catch (error) {
        console.warn(error)
    }
}


 